cc.Class({
    extends: cc.Component,

    properties: {
        // 敌人位置
        enemyPathNodePos: {
            default: [],
            type: cc.Node
        },
        // 塔防位置
        towerPosNodes: {
            default: [],
            type: cc.Node
        },
        buildMenuPrefab: {
            default: null,
            type: cc.Prefab
        }
    },

    // LIFE-CYCLE CALLBACKS:
    // initialization
    onLoad () {
        for (let i = 0; i < this.towerPosNodes.length; ++i) {
            let node = this.towerPosNodes[i];
            this.setTouchEvent(node);
        }
    },

    start () {

    },

    // update (dt) {},
    setTouchEvent: function (node) {
        node.on(cc.Node.EventType.TOUCH_START, (event) => {
            cc.log(`node touched with node name = ${node.name}`);
            this.showBuildMenu(node);
        })
    },
    showBuildMenu: function (node) {
        let menu = cc.instantiate(this.buildMenuPrefab);
        menu.parent = this.node;
        menu.position = node.position;
    }
});
